package com.flow.dao.impl;

import java.util.ArrayList;
import java.util.List;
import com.flow.dao.IPermissionMenuDao;
import com.flow.model.PagerModel;
import com.flow.model.PermissionMenu;

/**
 * 角色菜单DAO
 * @author wang
 * @2015-12-26 PermissionMenuDao.java
 * @param <T>
 * 
 */
public class PermissionMenuDao<T> extends BaseDao<T> implements IPermissionMenuDao<T> {

	@Override
	public boolean insertPermissionMenu(PermissionMenu permissionMenu) {

		try {

			insert(permissionMenu);
			return true;

		} catch (Exception e) {

			e.printStackTrace();

		}

		return false;
	}

	@Override
	public boolean updatePermissionMenu(PermissionMenu permissionMenu) {
		
		try {

			update(permissionMenu);
			return true;

		} catch (Exception e) {

			e.printStackTrace();

		}
		
		return false;
	}

	@Override
	public boolean deletePermissionMenu(PermissionMenu permissionMenu) {
		
		try {

			delete(permissionMenu);
			return true;

		} catch (Exception e) {

			e.printStackTrace();

		}
		
		return false;
	}

	@Override
	public PermissionMenu findPermissionMenuByHql(String hql) {

		return findPermissionMenuByHql(hql, null);
		
	}

	@Override
	public PermissionMenu findPermissionMenuByHql(String hql, Object param) {

		List<Object> params  = new ArrayList<Object>();
		params.add(param);
		return findPermissionMenuByHql(hql, params);
		
	}

	@Override
	public PermissionMenu findPermissionMenuByHql(String hql, List<Object> params) {
		
		return (PermissionMenu) findByHql(hql, params);
		
	}

	@Override
	public int universalMethodPermissionMenu(String hql) {

		return universalMethodPermissionMenu(hql, null);
		
	}

	@Override
	public int universalMethodPermissionMenu(String hql, Object param) {

		List<Object> params  = new ArrayList<Object>();
		params.add(param);
		return universalMethodPermissionMenu(hql, params);
		
	}

	@Override
	public int universalMethodPermissionMenu(String hql, List<Object> params) {

		return universalMethod(hql, params);
	}

	@Override
	public List<T> findPermissionMenuAllByHql(String hql) {

		return findPermissionMenuAllByHql(hql, null);
	}

	@Override
	public List<T> findPermissionMenuAllByHql(String hql, Object param) {

		List<Object> params  = new ArrayList<Object>();
		params.add(param);
		return findPermissionMenuAllByHql(hql, params);
		
	}

	@Override
	public List<T> findPermissionMenuAllByHql(String hql, List<Object> params) {

		return findAllByHql(hql, params);
	}

	@Override
	public PagerModel findPermissionMenuPagerModeled(PagerModel pager, String hql) {
		
		return findPermissionMenuPagerModeled(pager, hql, null);
		
	}

	@Override
	public PagerModel findPermissionMenuPagerModeled(PagerModel pager, String hql, Object param) {
		
		List<Object> params  = new ArrayList<Object>();
		params.add(param);
		return findPermissionMenuPagerModeled(pager, hql, params);
		
	}

	@Override
	public PagerModel findPermissionMenuPagerModeled(PagerModel pager, String hql, List<Object> params) {

		return findPagerModeled(pager, hql, params);
		
	}

}
